home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: New Zealand Amiga Users Group / New Zealand Amiga Users Group Newsdisk v03 (1987-02)(NZAmigaUG).zip / New Zealand Amiga Users Group Newsdisk v03 (1987-02)(NZAmigaUG).adf / AutoIconOpen.c < prev    next >
C/C++ Source or Header  |  1993-12-02  |  5KB  |  126 lines

  1. /* PROGRAM : AutoIconOpen.c
  2.    AUTHOR  : Tony (**all at sea in c**) Wills.
  3.    DATE    : 15 FEB 87.
  4.    PURPOSE : To fool WorkBench into thinking it is recieving mouse inputs
  5.              that select & open icons.
  6.              Original application was to automatically open your disk icon
  7.              on bootup - and perhaps display instructions.  For use in
  8.              our NewsDisk (=newsletter on a disk, along the lines of
  9.              JumpDisk and Amigazine).
  10.  
  11.    This is a very simplistic program, and ignores all sorts of conventions
  12.    that might otherwise ensure it will work in many different environments.
  13.    (Just like the examples in the Amiga Technical manuals !!!, which this
  14.     program is based on.)
  15.    1) It assumes that the screen is 640x200 on startup
  16.    2) It assumes there is a cli window in front with it's bottom corner
  17.       at 640/400. It resizes this window to 540x200
  18.    3) This is expected to expose the disk icons residing in the top right
  19.       hand corner of the screen.
  20.    4) It opens the icon in the top righthand position by sending a double
  21.       click sequence.
  22.    5) All done, so closes input.device and exits.
  23.  
  24.    Bugs, oversights, and possible improvements :
  25.    1) Doesn't allocate anything in public address space so won't work on
  26.       future hardware with a MMU that stops programs getting at others
  27.       address space - I'm sure that this is the least of this programs
  28.       problems!
  29.    2) I thought I was working on a 640x200 screen but have to move twice
  30.       as far vertically as I would expect! 
  31.    3) Could string all events together using ie_NextEvent pointers, but not
  32.       much point for this application.
  33. */
  34.  
  35. #include <exec/types.h>
  36. #include <exec/io.h>
  37. #include <devices/input.h>
  38. #include <exec/devices.h>
  39. #include <devices/inputevent.h>
  40.  
  41. struct IOStdReq    input_request_block;
  42. struct InputEvent  SimulatedEvent;
  43.  
  44. main()
  45. {
  46. if (OpenDevice("input.device",0,&input_request_block,0) != 0) {
  47.   exit(-1);
  48. }
  49.  
  50. input_request_block.io_Command = IND_WRITEEVENT;
  51. input_request_block.io_Flags   = 0;
  52. input_request_block.io_Length  = sizeof(struct InputEvent);
  53. input_request_block.io_Data    = &SimulatedEvent;
  54.  
  55. /* Blat pointer into bottom, righthand corner, doesn't really matter where
  56.    we start from. I thought IECLASS_POINTERPOS or setting ie_Qualifier to
  57.    0 might give me absolute positioning - but didn't seem to do what I
  58.    expected.  Press left button when you get there */
  59. SimulatedEvent.ie_NextEvent          = NULL;
  60. SimulatedEvent.ie_Class              = IECLASS_RAWMOUSE;
  61. SimulatedEvent.ie_TimeStamp.tv_secs  = 0;
  62. SimulatedEvent.ie_TimeStamp.tv_micro = 0;
  63. SimulatedEvent.ie_Code               = IECODE_LBUTTON;
  64. SimulatedEvent.ie_Qualifier          = IEQUALIFIER_RELATIVEMOUSE;
  65. SimulatedEvent.ie_X                  = 640;
  66. SimulatedEvent.ie_Y                  = 400;
  67.  
  68. DoIO(&input_request_block);
  69.  
  70. /* Move left 100 while holding left button down, and release button - ie
  71.    resize the CLI window I expect to be there - If nothing's there then
  72.    it doesn't really matter!  */
  73. SimulatedEvent.ie_NextEvent          = NULL;
  74. SimulatedEvent.ie_Class              = IECLASS_RAWMOUSE;
  75. SimulatedEvent.ie_TimeStamp.tv_secs  = 0;
  76. SimulatedEvent.ie_TimeStamp.tv_micro = 0;
  77. SimulatedEvent.ie_Code               = IECODE_LBUTTON | IECODE_UP_PREFIX;
  78. SimulatedEvent.ie_Qualifier          = IEQUALIFIER_RELATIVEMOUSE;
  79. SimulatedEvent.ie_X                  = -100;
  80. SimulatedEvent.ie_Y                  = 0;
  81.  
  82. DoIO(&input_request_block);
  83.  
  84. /* Move to where I expect disk icon to be (595,22), but note I seem to
  85.    have to move to (595,45) as though the vertical resolution is double
  86.    what I think it is! */
  87. SimulatedEvent.ie_NextEvent          = NULL;
  88. SimulatedEvent.ie_Class              = IECLASS_RAWMOUSE;
  89. SimulatedEvent.ie_TimeStamp.tv_secs  = 0;
  90. SimulatedEvent.ie_TimeStamp.tv_micro = 0;
  91. SimulatedEvent.ie_Code               = IECODE_NOBUTTON;
  92. SimulatedEvent.ie_Qualifier          = IEQUALIFIER_RELATIVEMOUSE;
  93. SimulatedEvent.ie_X                  = 55;
  94. SimulatedEvent.ie_Y                  = -355;
  95.  
  96. DoIO(&input_request_block);
  97.  
  98. /* Press left button without moving */
  99. SimulatedEvent.ie_NextEvent          = NULL;
  100. SimulatedEvent.ie_Class              = IECLASS_RAWMOUSE;
  101. SimulatedEvent.ie_TimeStamp.tv_secs  = 0;
  102. SimulatedEvent.ie_TimeStamp.tv_micro = 0;
  103. SimulatedEvent.ie_Code               = IECODE_LBUTTON;
  104. SimulatedEvent.ie_Qualifier          = IEQUALIFIER_RELATIVEMOUSE;
  105. SimulatedEvent.ie_X                  = 0;
  106. SimulatedEvent.ie_Y                  = 0;
  107.  
  108. DoIO(&input_request_block);
  109.  
  110. /* Press left button again. Note I didn't release button in between but it
  111.    doesn't seem to matter! */
  112. SimulatedEvent.ie_NextEvent          = NULL;
  113. SimulatedEvent.ie_Class              = IECLASS_RAWMOUSE;
  114. SimulatedEvent.ie_TimeStamp.tv_secs  = 0;
  115. SimulatedEvent.ie_TimeStamp.tv_micro = 0;
  116. SimulatedEvent.ie_Code               = IECODE_LBUTTON;
  117. SimulatedEvent.ie_Qualifier          = IEQUALIFIER_RELATIVEMOUSE;
  118. SimulatedEvent.ie_X                  = 0;
  119. SimulatedEvent.ie_Y                  = 0;
  120.  
  121. DoIO(&input_request_block);
  122.  
  123. /* All done so pack up and go home */
  124. CloseDevice(&input_request_block);
  125. }
  126.